package com.example.qihuibao.utils

import android.app.Activity
import com.example.qihuibao.XApplication
import com.example.qihuibao.bean.CheckNewVersionResponseBean
import com.example.qihuibao.network.RetrofitModel
import com.maning.updatelibrary.InstallUtils

object UpgradeAppUtil {
    val apkDir = "${XApplication.application.getExternalFilesDir("")?.path}/"

    fun checkNewVersion(back:(bean:CheckNewVersionResponseBean)->Unit) {
        val jsonObj = org.json.JSONObject()
        RetrofitModel.postJson("/source/auth/eg-access/access", jsonObj, object : RetrofitModel.Result<CheckNewVersionResponseBean> {
            override fun onSucced(result: CheckNewVersionResponseBean) {
                //todo for test
//                result.hasNewVersion = true
//                result.version = "1.0.0.0"
//                result.apkUrl = "https://ucan.25pp.com/PPAssistant_PP_103.apk"
                //
                back(result)
            }

            override fun onFailed(errMsg: String) {
                back(CheckNewVersionResponseBean(errMsg = errMsg))
            }
        })
    }
}